//
//  PreferencesController.m
//  iMine
//
//  Created by gaoxiang on 09-3-15.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "PreferencesController.h"


@implementation PreferencesController

- (id)init
{
	if (![super init])
		return nil;
	
	return self;
}
								 
- (NSString *)windowNibName
{
	return @"Preferences";
}

- (void)windowDidBecomeMain:(NSNotification *)notification
{
	[mineFieldWidth setIntValue:[[GameEngine sharedGameEngine] rows]];
	[mineFieldHeight setIntValue:[[GameEngine sharedGameEngine] cols]];
	[mineCount setIntValue:[[GameEngine sharedGameEngine] mineNumber]];
	[widthStepper setIntValue:[[GameEngine sharedGameEngine] rows]];
	[heightStepper setIntValue:[[GameEngine sharedGameEngine] cols]];
	[countStepper setIntValue:[[GameEngine sharedGameEngine] mineNumber]];
}

- (IBAction)close:(id)sender
{
	[self close];
}

- (IBAction)apply:(id)sender
{
	[[GameEngine sharedGameEngine] newCustomGame:[mineFieldHeight intValue] withColumn:[mineFieldWidth intValue] withMineNumber:[mineCount intValue]];
	
	[self close];
}

- (IBAction)widthChanged:(id)sender
{
	[mineFieldWidth setIntValue:[widthStepper intValue]];
}

- (IBAction)heightChanged:(id)sender
{
	[mineFieldHeight setIntValue:[heightStepper intValue]];
}

- (IBAction)countChanged:(id)sender
{
	[mineCount setIntValue:[countStepper intValue]];
}

@end
